package com.itcast.n9_垃圾回收;

import com.itcast.my.A;
import com.itcast.my.B;

import java.io.IOException;

/**
 * @program: jvm
 * @description: -verbose:gc
 * @author: flyduck
 * @create: 2024-09-23 16:30
 **/
public class Test05_通过模拟循环引用查看java是否使用了引用计数法 {

    public static void main(String[] args) throws IOException {
        while (true) {
            A1 a1 = new A1();
            B1 b1 = new B1();
            a1.b1 = b1;
            b1.a1 = a1;
            a1 = null;
            b1 = null;
            System.gc();
        }
    }
}

class A1 {
    B1 b1;
}

class B1 {
    A1 a1;
}
